﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Common
{
    /// <summary>
    /// 日期相关函数
    /// </summary>
    /// <remarks>
    /// <para>Fuyuanzhao</para>
    /// <para>2013.01.17</para>
    /// </remarks>
    public class DateHelper
    {
        /// <summary>
        /// 判断选择的日期是否是本周
        /// </summary>
        /// <param name="someDate"></param>
        /// <returns></returns>
        public static bool IsThisWeek(DateTime someDate)
        {
            DateTime dt = DateTime.Now;
            int iDayNum = 1;
            if (int.Parse(dt.DayOfWeek.ToString("d")) == 0)
            {
                iDayNum = 7;
            }
            DateTime nowMon = dt.AddDays(1 - iDayNum);
            TimeSpan ts = someDate - nowMon;
            if (ts.Days >= 0 && ts.Days < 7)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
        /// <summary>
        /// 判断选择的日期是否是今天
        /// </summary>
        /// <param name="someDate"></param>
        /// <returns></returns>
        public static bool IsToday(DateTime someDate)
        {
            DateTime dt = Convert.ToDateTime(DateTime.Now.ToShortDateString());
            TimeSpan ts = someDate - dt;
            if (ts.Hours > 0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}
